package org.springframework.nio.handler.adapter;

import org.springframework.core.Ordered;
import org.springframework.nio.NioRequest;
import org.springframework.nio.context.support.NioApplicationObjectSupport;
import org.springframework.nio.method.HandlerMethod;

public abstract class AbstractHandlerAdapter extends NioApplicationObjectSupport implements SimpHandlerAdapter ,Ordered{

	private int order = Ordered.LOWEST_PRECEDENCE;
	
	
	
	

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	@Override
	public final boolean support(Object handler) {
		return handler instanceof HandlerMethod && supportInternal((HandlerMethod) handler);
	}

	public abstract boolean supportInternal(HandlerMethod handler);
	
	@Override
	public final Object handle(NioRequest<?> request, Object handler) throws Exception {
		return handleInternal(request, (HandlerMethod) handler);
		
	}
	public abstract Object handleInternal(NioRequest<?> request, HandlerMethod handler) throws Exception;

}
